//引入mongoose
const mongoose = require('mongoose');
//连接数据库
let url = process.env.DATABASE_URL || `mongodb://localhost:27017/blog_v2`;
mongoose.set('useNewUrlParser', true);
mongoose.set('useFindAndModify', false);
mongoose.set('useCreateIndex', true);
mongoose.connect(url,{useUnifiedTopology: true})
  .then(()=>{console.log("数据库连接成功！")})
  .catch((err)=>{console.log("数据库连接失败！",err)})